package com.zznj.xzjc.fragment.ztgk;

import android.view.View;
import android.widget.TextView;

import com.google.gson.Gson;
import com.vondear.rxui.fragment.NewLazyFragment;
import com.zznj.xzjc.R;
import com.zznj.xzjc.bean.index.AjblData;
import com.zznj.xzjc.net.SharedHelper;
import com.zznj.xzjc.net.entity.BaseBean;
import com.zznj.xzjc.net.entity.LoginBean;
import com.zznj.xzjc.net.rxjava.HttpMethods;
import com.zznj.xzjc.net.subscribers.ProgressSubscriber;
import com.zznj.xzjc.net.subscribers.SubscriberOnNextListener;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import okhttp3.FormBody;

/**
 * 描述：知识库
 */
public class AjblFragment extends NewLazyFragment {
    @BindView(R.id.xzslNum)
    TextView xzslNum;
    @BindView(R.id.xzlaNum)
    TextView xzlaNum;
    @BindView(R.id.bylaNum)
    TextView bylaNum;
    @BindView(R.id.xzcfNum)
    TextView xzcfNum;
    @BindView(R.id.yxzzxNum)
    TextView yxzzxNum;
    @BindView(R.id.qzzxNum)
    TextView qzzxNum;
    @BindView(R.id.chsqNum)
    TextView chsqNum;
    @BindView(R.id.xzfyNum)
    TextView xzfyNum;




    @BindView(R.id.fyslNum)
    TextView fyslNum;
    @BindView(R.id.byslNum)
    TextView byslNum;
    @BindView(R.id.fylaNum)
    TextView fylaNum;
    @BindView(R.id.fyhjbylaNum)
    TextView fyhjbylaNum;
    @BindView(R.id.zyzxNum)
    TextView zyzxNum;
    @BindView(R.id.byzxNum)
    TextView byzxNum;
    @BindView(R.id.zjbczxNum)
    TextView zjbczxNum;
    @BindView(R.id.zjzxNum)
    TextView zjzxNum;
    @BindView(R.id.zxwbNum)
    TextView zxwbNum;

    Unbinder unbinder;
    private boolean isShowDialog = true;


    public static AjblFragment getInstance() {
        AjblFragment fragment = new AjblFragment();
        return fragment;
    }

    @Override
    protected int getContentViewId() {
        return R.layout.gyss_fragment_ztgk_ajbl_layout;
    }

    private LoginBean user;

    @Override
    protected void initView(View view) {
        unbinder = ButterKnife.bind(this, view);
        user = new Gson().fromJson(SharedHelper.readValueByKeyForString(mContext, "Member"), LoginBean.class);
        super.initView(view);
    }

    @Override
    protected void initData() {
    }

    @Override
    public void onResume() {
        super.onResume();
        getData();
    }

    private void getData() {
        SubscriberOnNextListener<BaseBean<AjblData>> onNextListener = baseBean -> {
            xzslNum.setText(baseBean.getResult().getTotalNum()+"");
            xzlaNum.setText(baseBean.getResult().getXingzhenglianNum()+"");
            bylaNum.setText(baseBean.getResult().getXingzhengnolianNum()+"");
            xzcfNum.setText(baseBean.getResult().getPenaltyNum()+"");
            yxzzxNum.setText(baseBean.getResult().getZhixingNum()+"");
            qzzxNum.setText(baseBean.getResult().getApplyenforceNum()+"");
            chsqNum.setText(baseBean.getResult().getUndoenforceNum()+"");
            xzfyNum.setText(baseBean.getResult().getFuyiNum()+"");


            fyslNum.setText(baseBean.getResult().getFyslNum()+"");
            byslNum.setText(baseBean.getResult().getFybyslNum()+"");
            fylaNum.setText(baseBean.getResult().getCourtlianNum()+"");
            fyhjbylaNum.setText(baseBean.getResult().getCourtnolianNum()+"");
            zyzxNum.setText(baseBean.getResult().getEnforceNum()+"");
            byzxNum.setText(baseBean.getResult().getNoperformNum()+"");
            zjbczxNum.setText(baseBean.getResult().getTerminationNum()+"");
            zjzxNum.setText(baseBean.getResult().getZjzxNum()+"");
            zxwbNum.setText(baseBean.getResult().getZxwbNum()+"");
        };
        FormBody requestBody = new FormBody.Builder()
                .add("districtJB", "")
                .build();
        HttpMethods.getInstance().feisuCaseData(new ProgressSubscriber<>(onNextListener, mContext, true), requestBody);
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
        unbinder.unbind();
    }
}